package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Note;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.NoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.util.Arrays;

/**
 * @author 邵康
 * @date 2021/11/24 19:22
 */
@CrossOrigin
@RestController
@RequestMapping("/note")
@Api(tags = "图文动态")
public class NoteController {

    @Autowired
    private NoteService noteService;

//    @ApiOperation("转发图文动态,NoteId,转发评论必须 ")
//    @GetMapping("/forward")
//    public R<Void> forward(Integer id, String content, HttpSession session){
//        return noteService.forward(id,content,session);
//    }

    @ApiOperation("添加图文动态 文本内容  images非必须  会触发动态更新")
    @PostMapping("/add")
    public R<Void> add(Note note) {
        return noteService.add(note);
    }

    @ApiOperation("根据Id删除动态")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return noteService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Note note) {
        return noteService.update(note);
    }

    @ApiOperation("根据Id获取图文动态的详细信息")
    @GetMapping("/getNote")
    public R<Note> getNote(Integer id){
        return noteService.getNote(id);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Note>> page(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer size) {
        return noteService.page(page, size);
    }

}
